package com.you.pattern.observer.demo2;

public class Main {

    public static void main(String[] args) {
        Student student = Student.getInstance();
        Teacher teacher1 = new Teacher("老师1");
        Teacher teacher2 = new Teacher("老师2");
        student.addObservers(teacher1);
        student.addObservers(teacher2);

        //业务逻辑代码
        Question question = new Question();
        question.setUserName("小明");
        question.setContent("观察者模式适用于哪些场景？");
        student.publishQuestion(question);
    }
}
